//
//  HomePageCardTableViewCell.m
//  DBAChain
//
//  Created by Evan on 2018/9/5.
//  Copyright © 2018 Evan. All rights reserved.
//

#import "HomePageCardTableViewCell.h"
#import <Masonry.h>
#import "CommonData.h"
#import "HomePageCardView.h"
#import "dataMinerMainList.h"

@implementation HomePageCardTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(UIView*)viewBg{
    if (!_viewBg) {
        _viewBg = [[UIView alloc]init];
        [self addSubview:_viewBg];
        [_viewBg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self).offset(0);
            make.right.mas_equalTo(self).offset(-20);
            make.left.mas_equalTo(self).offset(20);
            make.top.mas_equalTo(self).offset(0);
        }];
        _viewBg.backgroundColor = [UIColor whiteColor];
        
        _viewBg.layer.shadowColor = [UIColor blackColor].CGColor;
        //        阴影的透明度
        _viewBg.layer.shadowOpacity = 0.3f;
        //        阴影的圆角
        _viewBg.layer.shadowRadius = 4.0f;
    }
    return _viewBg;
}

-(void)setDataArray:(NSArray<dataMinerMainList*>* )arrayData pmView:(PMViewController*)pmView{

    for (UIView *view in [self.viewBg subviews]) {
        [view removeFromSuperview];
    }

    for (int i =0; i<[arrayData count]; i++) {
        HomePageCardView *viewCard = [[HomePageCardView alloc]init];
        [self.viewBg addSubview:viewCard];
        [viewCard mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.offset(200);
            make.right.mas_equalTo(self.viewBg.mas_right).offset(-25);
            make.left.mas_equalTo(self.viewBg.mas_left).offset(-15);
            make.top.mas_equalTo(self.viewBg).offset(-5 + (180*(i)));
        }];
        
       dataMinerMainList *model = [dataMinerMainList mj_objectWithKeyValues:[arrayData objectAtIndex:i]];
        viewCard.labelTitle.text = model.name;
        ///单位算力
        viewCard.labelDslDes.text = [NSString stringWithFormat:@"%@/天",model.unitEfficiency];
        viewCard.labelYslDes.text = [NSString stringWithFormat:@"%@GTE",model.usedEfficiency];
        
        viewCard.labelZslDes.text = [NSString stringWithFormat:@"%@GTE",model.totalEfficiency];
        
        viewCard.labelZCount.text = [NSString stringWithFormat:@"算码总量：%@枚",model.minerCount];
        viewCard.labelSYCount.text = [NSString stringWithFormat:@"剩余：%@枚",model.remainMinerCount];
        
        UITapGestureRecognizer *gest = [[UITapGestureRecognizer alloc]initWithTarget:pmView action:@selector(btnSuanMaClick:)];
        viewCard.tag = i;
        [viewCard addGestureRecognizer:gest];
    }
    
}


@end
